namespace rptDataSetTableAdapters
{
    using System;
    using System.CodeDom.Compiler;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Configuration;
    using System.Data;
    using System.Data.Common;
    using System.Data.SqlClient;
    using System.Diagnostics;

    [HelpKeyword("vs.data.TableAdapter"), GeneratedCode("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), DesignerCategory("code"), ToolboxItem(true), DataObject(true), Designer("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
    public class ConNguoi_nguoiTableAdapter : Component
    {
        private SqlDataAdapter _adapter;
        private bool _clearBeforeFill;
        private SqlCommand[] _commandCollection;
        private SqlConnection _connection;

        [DebuggerNonUserCode]
        public ConNguoi_nguoiTableAdapter()
        {
            this.ClearBeforeFill = true;
        }

        [DataObjectMethod(DataObjectMethodType.Delete, true), HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual int Delete(int Original_ma_nguoi)
        {
            int num2;
            this.Adapter.DeleteCommand.Parameters[0].Value = Original_ma_nguoi;
            ConnectionState state = this.Adapter.DeleteCommand.Connection.State;
            if ((this.Adapter.DeleteCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
            {
                this.Adapter.DeleteCommand.Connection.Open();
            }
            try
            {
                num2 = this.Adapter.DeleteCommand.ExecuteNonQuery();
            }
            finally
            {
                if (state == ConnectionState.Closed)
                {
                    this.Adapter.DeleteCommand.Connection.Close();
                }
            }
            return num2;
        }

        [DebuggerNonUserCode, DataObjectMethod(DataObjectMethodType.Fill, true), HelpKeyword("vs.data.TableAdapter")]
        public virtual int Fill(rptDataSet.ConNguoi_nguoiDataTable dataTable)
        {
            this.Adapter.SelectCommand = this.CommandCollection[0];
            if (this.ClearBeforeFill)
            {
                dataTable.Clear();
            }
            return this.Adapter.Fill(dataTable);
        }

        [DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter"), DataObjectMethod(DataObjectMethodType.Select, true)]
        public virtual rptDataSet.ConNguoi_nguoiDataTable GetData()
        {
            this.Adapter.SelectCommand = this.CommandCollection[0];
            rptDataSet.ConNguoi_nguoiDataTable dataTable = new rptDataSet.ConNguoi_nguoiDataTable();
            this.Adapter.Fill(dataTable);
            return dataTable;
        }

        [DebuggerNonUserCode]
        private void InitAdapter()
        {
            this._adapter = new SqlDataAdapter();
            DataTableMapping mapping = new DataTableMapping();
            mapping.SourceTable = "Table";
            mapping.DataSetTable = "ConNguoi_nguoi";
            mapping.ColumnMappings.Add("ma_nguoi", "ma_nguoi");
            mapping.ColumnMappings.Add("ho_ten", "ho_ten");
            mapping.ColumnMappings.Add("ngay_sinh", "ngay_sinh");
            mapping.ColumnMappings.Add("gioi_tinh", "gioi_tinh");
            mapping.ColumnMappings.Add("cmnd", "cmnd");
            mapping.ColumnMappings.Add("dien_thoai_nha", "dien_thoai_nha");
            mapping.ColumnMappings.Add("dien_thoai_di_dong", "dien_thoai_di_dong");
            mapping.ColumnMappings.Add("email", "email");
            mapping.ColumnMappings.Add("dia_chi_chi_tiet", "dia_chi_chi_tiet");
            mapping.ColumnMappings.Add("tai_khoan", "tai_khoan");
            mapping.ColumnMappings.Add("ho_khau", "ho_khau");
            mapping.ColumnMappings.Add("thanh_pho", "thanh_pho");
            this._adapter.TableMappings.Add(mapping);
            this._adapter.DeleteCommand = new SqlCommand();
            this._adapter.DeleteCommand.Connection = this.Connection;
            this._adapter.DeleteCommand.CommandText = "DELETE FROM [ConNguoi_nguoi] WHERE (([ma_nguoi] = @Original_ma_nguoi))";
            this._adapter.DeleteCommand.CommandType = CommandType.Text;
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@Original_ma_nguoi", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "ma_nguoi", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.UpdateCommand = new SqlCommand();
            this._adapter.UpdateCommand.Connection = this.Connection;
            this._adapter.UpdateCommand.CommandText = "UPDATE [ConNguoi_nguoi] SET [tai_khoan] = @tai_khoan, [ho_ten] = @ho_ten, [ngay_sinh] = @ngay_sinh, [gioi_tinh] = @gioi_tinh, [cmnd] = @cmnd, [dien_thoai_nha] = @dien_thoai_nha, [dien_thoai_di_dong] = @dien_thoai_di_dong, [email] = @email, [dia_chi_chi_tiet] = @dia_chi_chi_tiet WHERE (([ma_nguoi] = @Original_ma_nguoi))";
            this._adapter.UpdateCommand.CommandType = CommandType.Text;
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@tai_khoan", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "tai_khoan", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@ho_ten", SqlDbType.NVarChar, 0, ParameterDirection.Input, 0, 0, "ho_ten", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@ngay_sinh", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "ngay_sinh", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@gioi_tinh", SqlDbType.Bit, 0, ParameterDirection.Input, 0, 0, "gioi_tinh", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@cmnd", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "cmnd", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@dien_thoai_nha", SqlDbType.NVarChar, 0, ParameterDirection.Input, 0, 0, "dien_thoai_nha", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@dien_thoai_di_dong", SqlDbType.NVarChar, 0, ParameterDirection.Input, 0, 0, "dien_thoai_di_dong", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@email", SqlDbType.NVarChar, 0, ParameterDirection.Input, 0, 0, "email", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@dia_chi_chi_tiet", SqlDbType.NVarChar, 0, ParameterDirection.Input, 0, 0, "dia_chi_chi_tiet", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Original_ma_nguoi", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "ma_nguoi", DataRowVersion.Original, false, null, "", "", ""));
        }

        [DebuggerNonUserCode]
        private void InitCommandCollection()
        {
            this._commandCollection = new SqlCommand[] { new SqlCommand() };
            this._commandCollection[0].Connection = this.Connection;
            this._commandCollection[0].CommandText = "select \r\n\tma_nguoi,\r\n\ttai_khoan,\r\n\tho_ten,\r\n\tdbo.fcGetDiaChiChiTiet(ho_khau) as ho_khau,\r\n                  dbo.fcGetThanhPho(ho_khau) as thanh_pho,\r\n\tngay_sinh,\r\n\tgioi_tinh,\r\n\tcmnd,\r\n\tdien_thoai_nha,\r\n\tdien_thoai_di_dong,\r\n\temail,\r\n\tdia_chi_chi_tiet\r\nfrom ConNguoi_nguoi";
            this._commandCollection[0].CommandType = CommandType.Text;
        }

        [DebuggerNonUserCode]
        private void InitConnection()
        {
            this._connection = new SqlConnection();
            this._connection.ConnectionString = ConfigurationManager.ConnectionStrings["SLD_testConnectionString"].ConnectionString;
        }

        [DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter")]
        public virtual int Update(rptDataSet dataSet)
        {
            return this.Adapter.Update(dataSet, "ConNguoi_nguoi");
        }

        [HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual int Update(DataRow dataRow)
        {
            return this.Adapter.Update(new DataRow[] { dataRow });
        }

        [HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual int Update(DataRow[] dataRows)
        {
            return this.Adapter.Update(dataRows);
        }

        [HelpKeyword("vs.data.TableAdapter"), DebuggerNonUserCode]
        public virtual int Update(rptDataSet.ConNguoi_nguoiDataTable dataTable)
        {
            return this.Adapter.Update(dataTable);
        }

        [DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter"), DataObjectMethod(DataObjectMethodType.Update, true)]
        public virtual int Update(string tai_khoan, string ho_ten, DateTime ngay_sinh, bool gioi_tinh, string cmnd, string dien_thoai_nha, string dien_thoai_di_dong, string email, string dia_chi_chi_tiet, int Original_ma_nguoi)
        {
            int num2;
            if (tai_khoan == null)
            {
                this.Adapter.UpdateCommand.Parameters[0].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[0].Value = tai_khoan;
            }
            if (ho_ten == null)
            {
                throw new ArgumentNullException("ho_ten");
            }
            this.Adapter.UpdateCommand.Parameters[1].Value = ho_ten;
            this.Adapter.UpdateCommand.Parameters[2].Value = ngay_sinh;
            this.Adapter.UpdateCommand.Parameters[3].Value = gioi_tinh;
            if (cmnd == null)
            {
                this.Adapter.UpdateCommand.Parameters[4].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[4].Value = cmnd;
            }
            if (dien_thoai_nha == null)
            {
                this.Adapter.UpdateCommand.Parameters[5].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[5].Value = dien_thoai_nha;
            }
            if (dien_thoai_di_dong == null)
            {
                this.Adapter.UpdateCommand.Parameters[6].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[6].Value = dien_thoai_di_dong;
            }
            if (email == null)
            {
                this.Adapter.UpdateCommand.Parameters[7].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[7].Value = email;
            }
            if (dia_chi_chi_tiet == null)
            {
                this.Adapter.UpdateCommand.Parameters[8].Value = DBNull.Value;
            }
            else
            {
                this.Adapter.UpdateCommand.Parameters[8].Value = dia_chi_chi_tiet;
            }
            this.Adapter.UpdateCommand.Parameters[9].Value = Original_ma_nguoi;
            ConnectionState state = this.Adapter.UpdateCommand.Connection.State;
            if ((this.Adapter.UpdateCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
            {
                this.Adapter.UpdateCommand.Connection.Open();
            }
            try
            {
                num2 = this.Adapter.UpdateCommand.ExecuteNonQuery();
            }
            finally
            {
                if (state == ConnectionState.Closed)
                {
                    this.Adapter.UpdateCommand.Connection.Close();
                }
            }
            return num2;
        }

        [DebuggerNonUserCode]
        private SqlDataAdapter Adapter
        {
            get
            {
                if (this._adapter == null)
                {
                    this.InitAdapter();
                }
                return this._adapter;
            }
        }

        [DebuggerNonUserCode]
        public bool ClearBeforeFill
        {
            get
            {
                return this._clearBeforeFill;
            }
            set
            {
                this._clearBeforeFill = value;
            }
        }

        [DebuggerNonUserCode]
        protected SqlCommand[] CommandCollection
        {
            get
            {
                if (this._commandCollection == null)
                {
                    this.InitCommandCollection();
                }
                return this._commandCollection;
            }
        }

        [DebuggerNonUserCode]
        internal SqlConnection Connection
        {
            get
            {
                if (this._connection == null)
                {
                    this.InitConnection();
                }
                return this._connection;
            }
            set
            {
                this._connection = value;
                if (this.Adapter.InsertCommand != null)
                {
                    this.Adapter.InsertCommand.Connection = value;
                }
                if (this.Adapter.DeleteCommand != null)
                {
                    this.Adapter.DeleteCommand.Connection = value;
                }
                if (this.Adapter.UpdateCommand != null)
                {
                    this.Adapter.UpdateCommand.Connection = value;
                }
                for (int i = 0; i < this.CommandCollection.Length; i++)
                {
                    if (this.CommandCollection[i] != null)
                    {
                        this.CommandCollection[i].Connection = value;
                    }
                }
            }
        }
    }
}

